package com.jt.controller;

import com.jt.pojo.User;
import com.jt.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/axios")
public class AxiosController {
    @Autowired
    private UserService userService;

    //@GetMapping("/getUserById")
//public User getUserById(Integer id){
//    return userService.findUserById(id);
//}
//@GetMapping("/user/{sex}/{age}")
//public List<User>getUserBySA(User user){
//    return userService.getUserBySA(user);
//    }
//@GetMapping("/getUser")
//    public List<User>getUser(User user){
//    return userService.getUser(user);
//}
//@GetMapping("/getUserByID")
//    public User getUserByID(Integer id){
//    return userService.getUserByID(id);
//}
//@GetMapping("/user/{name}/{sex}")
//   public List<User>findnS(User user){
//    return userService.findnS(user);
//}
//@GetMapping("/getuser")
//    public List<User>getuser(User user){
//    return userService.getuser(user);
//}
//@DeleteMapping("/deleteById")
//    public String deleteById(Integer id){
//    userService.deleteById(id);
//    return "删除数据成功";
//}
    @PostMapping("/saveUser")
    public String saveUser(@RequestBody User user) {

        userService.saveUser(user);
        return "新增用户成功!!!";
    }
@PutMapping("/updateUser")
    public String updateUser(@RequestBody User user){
    userService.updateUser(user);
    return "更新成功";
}
@PutMapping("/updateUser/{wherename}")
public String updateByName(@RequestBody User user,@PathVariable String wherename) {
    userService.updateByName(user, wherename);
    return"更新成功1111";
}
@GetMapping("/findAll")
    public List<User>findAll(){
        return userService.findAll();
}
}


